package com.cdie.myschool.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author 明祺奇-199000331
 * @date 2022/7/21 - 10:25
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    //在自定义配置类MyMVCconfig中,重写addCorsMappings()方法处理跨域问题
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOriginPatterns("*")
                .allowCredentials(true)
                .allowedMethods("GET", "POST", "DELETE", "PUT", "PATCH")
                .maxAge(3600 * 24);
    }
}
